#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 5;
using ll = long long;
int x[maxn], y[maxn], n;

ll work(ll Y, bool f) {
    ll res = 0;
    if (f == 0) {
        for (int i = 0; i < n; i++) res += abs(y[i] - Y);
    } else {
        for (int i = 0; i < n; i++) res += abs(Y + i - x[i]);
    }
    return res;
}

ll threeFind(ll l, ll r, bool f) {
    ll m1, m2, ret;
    ll val = 1e18;
    while (r - l >= 3) {
        m1 = l + (r - l) / 3;
        m2 = r - (r - l) / 3;
        if (work(m1, f) > work(m2, f))
            l = m1;
        else
            r = m2;
    }
    for (ll i = l; i <= r; i++) {
        ll res = work(i, f);
        if (val > res) val = res, ret = i;
    }
    return ret;
}

int main() {
    int T, kase = 1;
    scanf("%d", &T);
    for (; kase <= T; kase++) {
        scanf("%d", &n);
        for (int i = 0; i < n; i++) scanf("%d%d", x + i, y + i);
        sort(x, x + n);
        ll lim = 2e9;
        ll py = threeFind(-lim, lim, 0);
        ll px = threeFind(-lim, lim, 1);
        printf("Case #%d: %lld\n", kase, work(py, 0) + work(px, 1));
    }
}